Encoder, robot, and printer

ABSTRACT

An encoder includes a base portion, a scale portion that is provided to be relatively movable or rotatable with respect to the base portion, and has three or more marks which are different from each other, an imaging element that is disposed in the base portion, and images the marks, and an estimation portion that selects at least one reference image from among three or more reference images, performs template matching on a captured image in the imaging element by using the reference image, so as to detect positions of the marks, and estimates a movement state or a rotation state of the scale portion with respect to the base portion, in which the estimation portion predicts a reference image to be used for post-template matching on the basis of a result of pre-template matching, and performs the post-template matching by using the predicted reference image.

BACKGROUND 1. Technical Field

The present invention relates to an encoder, a robot, and a printer.

2. Related Art

An optical rotary encoder is generally known as one kind of encoder (for example, refer to JP-A-63-187118). For example, a rotary encoder is used for a robot provided with a robot arm having a rotatable joint, and detects rotation states such as a rotation angle, a rotation position, a number of rotations, and a rotation speed of the joint. The detection results are used for drive control of the joint, for example.

For example, the encoder disclosed in JP-A-63-187118 reads a code plate on which a numerical value pattern and a stripe pattern such as a gray code are formed with an imaging element, and detects a position on the basis of the read numerical value pattern and stripe pattern.

However, in the encoder disclosed in JP-A-63-187118, in order to realize high detection accuracy, a high definition pattern is required to be formed on a code plate, and considerably high accuracy is required for positioning when the code plate is provided. Thus, in the encoder disclosed in JP-A-63-187118, there is a problem in which it is hard to practically realize high detection accuracy.

SUMMARY

Advantage of some aspects of the invention is to provide an encoder with high detection accuracy and high a processing speed, and to provide a robot and a printer having the encoder.

The invention can be implemented as the following application examples or forms.

An encoder according to an application example includes a base portion; a scale portion that is provided to be relatively movable or rotatable with respect to the base portion, and has three or more marks which are different from each other; an imaging element that is disposed in the base portion, and images the marks; and an estimation portion that selects at least one reference image from among three or more reference images, performs template matching on a captured image in the imaging element by using the reference image, so as to detect positions of the marks, and estimates a movement state or a rotation state of the scale portion with respect to the base portion, in which, in template matching consecutively performed twice, the estimation portion predicts a reference image to be used for template matching performed later on the basis of a result of template matching performed first.

According to the encoder, template matching is used, and thus a movement state or a rotation state of the scale portion with respect to the base portion can be estimated with high accuracy even without using high definition marks, and, as a result, it is possible to increase detection accuracy. Since a reference image to be used for post-template matching is predicted, it is not necessary to retrieve a reference image to be used for the post-template matching from a plurality of reference images when pre-template matching is replaced with the post-template matching, and it is possible to increase a processing speed. As a result, it becomes easier to ensure an effect of increasing detection accuracy as described above.

In the encoder according to the application example, it is preferable that the scale portion is relatively rotatable with respect to the base portion.

With this configuration, it is possible to realize a rotary encoder.

It is preferable that the encoder according to the application example further includes a storage portion that stores the three or more reference images.

With this configuration, template matching can be performed by selecting an appropriate reference image stored in the storage portion.

In the encoder according to the application example, it is preferable that the estimation portion sets a retrieval region in a partial region of the captured image, and performs the template matching in the retrieval region.

With this configuration, the number of pixels of the retrieval region used for template matching can be reduced, and thus a calculation time related to the template matching can be reduced. Thus, even in a case where movement or rotation of the scale portion is fast, it is possible to perform highly accurate detection. Even if distortion or blurring of the outer peripheral portion of the captured image in the imaging element increases due to aberration of a lens disposed between the imaging element and the marks, a region in which such distortion or blurring is small is used as the retrieval region, and thus it is possible to minimize deterioration in the detection accuracy.

In the encoder according to the application example, it is preferable that in a case where positions of the marks detected in the template matching performed first are present in the retrieval region, the estimation portion predicts a reference image used for the template matching performed later.

With this configuration, it is possible to make pre-template matching smoothly transition to post-template matching.

In the encoder according to the application example, it is preferable that the estimation portion performs template matching by simultaneously using a plurality of reference images with respect to the retrieval region.

With this configuration, it is possible to increase detection accuracy.

In the encoder according to the application example, it is preferable that before the template matching performed first, the estimation portion obtains the maximum correlation value of the captured image and each reference image by sequentially using the three or more reference images with respect to the captured image, and selects at least one reference image from among the three or more reference images on the basis of the maximum correlation value.

With this configuration, it is possible to determine a reference image used for template matching before the template matching is performed.

A robot according to an application example includes a first member; a second member that is provided to be rotatable with respect to the first member; and the encoder according to the application example, in which the encoder detects a rotation state of the second member with respect to the first member.

According to the robot, since detection accuracy in the encoder, it is possible to control an operation of the robot with high accuracy by using a detection result in the encoder.

A printer according to an application example includes the encoder according to the application example.

According to the printer, since detection accuracy in the encoder, it is possible to control an operation of the printer with high accuracy by using a detection result in the encoder.

BRIEF DESCRIPTION OF THE DRAWINGS

The invention will be described with reference to the accompanying drawings, wherein like numbers reference like elements.

FIG. 1 is a side view illustrating a robot according to a first embodiment of the invention.

FIG. 2 is a sectional view illustrating an encoder provided in the robot illustrated in FIG. 1.

FIG. 3 is a diagram for explaining a scale portion provided in the encoder illustrated in FIG. 2.

FIG. 4 is a picture illustrating an enlarged dot pattern based on a dithering method.

FIG. 5 is a picture illustrating an enlarged dot pattern based on a dithering method, in which a density of dots is lower than in the case illustrated in FIG. 4.

FIG. 6 is a diagram for explaining a captured image obtained by an imaging element provided in the encoder illustrated in FIG. 2.

FIG. 7 is a diagram for explaining template matching in a retrieval region set in the captured image illustrated in FIG. 6.

FIG. 8 is a diagram illustrating a state in which a correlation value is deviated by one pixel from a state in which the correlation value is the maximum or the minimum during template matching.

FIG. 9 is a diagram illustrating a state in which a correlation value is the maximum or the minimum during template matching.

FIG. 10 is a diagram illustrating a state in which a correlation value is deviated by one pixel toward an opposite side to the state illustrated in FIG. 8 from a state in which the correlation value is the maximum or the minimum during template matching.

FIG. 11 is a diagram for explaining a plurality of marks formed on the scale portion illustrated in FIG. 3.

FIG. 12 is a diagram illustrating a state in which one mark is detected through template matching among the plurality of marks illustrated in FIG. 11.

FIG. 13 is a diagram for explaining prediction of a reference image used for post-template matching following the template matching (pre-template matching) illustrated in FIG. 12.

FIG. 14 is a flowchart illustrating a method of determining a reference image used for initial template matching.

FIG. 15 is a flowchart illustrating a method (prediction method) of determining a reference image used for post-template matching in the first embodiment.

FIG. 16 is a diagram illustrating a state in which two marks are detected through template matching among a plurality of marks in an encoder according to a second embodiment of the invention.

FIG. 17 is a diagram for explaining prediction of a reference image used for post-template matching following the template matching (pre-template matching) illustrated in FIG. 15.

FIG. 18 is a flowchart illustrating a method (prediction method) of determining a reference image used for post-template matching in the second embodiment.

FIG. 19 is a perspective view illustrating a robot according to a third embodiment of the invention.

FIG. 20 is a diagram illustrating a printer of an embodiment of the invention.

DESCRIPTION OF EXEMPLARY EMBODIMENTS

Hereinafter, an encoder, a robot, and a printer according to embodiments of the invention will be described in detail with reference to the accompanying drawings.

1. Robot First Embodiment

FIG. 1 is a side view illustrating a robot of a first embodiment of the invention. In the following description, for convenience of description, in FIG. 1, an upper part is referred to as an “upper side”, and a lower part is referred to as a “lower side”. In FIG. 1, a base side is referred to as a “basal end”, and an opposite side (end effector side) thereto is referred to as a “distal end”. In FIG. 1, an upward-and-downward direction is referred to as a “vertical direction”, and a leftward-and-rightward direction is referred to as a “horizontal direction”.

A robot 10 illustrated in FIG. 1, which is a so-called horizontal articulated robot (scalar robot), is used for a manufacturing process of manufacturing, for example, precision equipment, and can perform holding or transport of the precision equipment or components.

As illustrated in FIG. 1, the robot 10 includes a base 110, a first arm 120, a second arm 130, a work head 140, an end effector 150, and a wiring routing portion 160. Hereinafter, the respective portions of the robot 10 will be described briefly in order.

The base 110 is fixed to, for example, a floor surface (not illustrated) via bolts or the like. The first arm 120 is connected to an upper end of the base 110. The first arm 120 is rotatable about a first axis J1 along the vertical direction with respect to the base 110.

The base 110 is provided with a first motor 111 which generates drive force for rotating the first arm 120, and a first decelerator 112 which reduces the driving force from the first motor 111. An input shaft of the first decelerator 112 is connected to a rotation shaft of the first motor 111, and an output shaft of the first decelerator 112 is connected to the first arm 120. Thus, if the first motor 111 is driven, and a driving force therefrom is forwarded to the first arm 120 via the first decelerator 112, the first arm 120 is rotated about the first rotation axis J1 in a horizontal plane with respect to the base 110.

An encoder 1 which is a first encoder detecting a state of the first arm 120 being rotated with respect to the base 110 is provided at the base 110 and the first arm 120.

A distal end of the first arm 120 is connected to the second arm 130. The second arm 130 is rotatable about a second axis J2 along the vertical direction with respect to the first arm 120. Although not illustrated, the second arm 130 is provided with a second motor which generates drive force for rotating the second arm 130, and a second decelerator which reduces the driving force from the second motor. The driving force from the second motor is forwarded to the first arm 120 via the second decelerator, and thus the second arm 130 is rotated about the second axis J2 in a horizontal plane with respect to the first arm 120. Although not illustrated, the second motor is provided with a second encoder which detects a state of the second arm 130 being rotated with respect to the first arm 120.

The work head 140 is disposed at a distal end of the second arm 130. The work head 140 includes a spline shaft 141 inserted into a spline nut and a ball screw nut (none illustrated) which are disposed in the same scale at the distal end of the second arm 130. The spline shaft 141 can be rotated about an axis thereof and can be moved up and down in the vertical direction, with respect to the second arm 130.

Although not illustrated, the second arm 130 is provided with a rotation motor and a lifting motor. If drive force from the rotation motor is forwarded to the spline nut via a drive force forwarding mechanism (not illustrated), and thus the spline nut is rotated in normal and reverse directions, the spline shaft 141 is rotated in the normal and reverse directions about an axis J3 along the vertical direction. Although not illustrated, the rotation motor is provided with a third encoder which detects a state of the spline shaft 141 being rotated with respect to the second arm 130.

On the other hand, if drive force from the lifting motor is forwarded to the ball screw nut via a drive force forwarding mechanism (not illustrated), and thus the ball screw nut is rotated in normal and reverse directions, the spline shaft 141 is moved up and down. The lifting motor is provided with a fourth encoder detecting a movement amount of the spline shaft 141 with respect to the second arm 130.

A distal end (lower end) of the spline shaft 141 is connected to the end effector 150. The end effector 150 is not particularly limited, and may employ, for example, an effector holding an object to be transported, or an effector processing an object to be processed.

A plurality of wires connected to the respective electronic components (for example, the second motor, the rotation motor, the lifting motor, and the first to fourth encoders) disposed in the second arm 130 are routed to the base 110 through the tubular wiring routing portion 160 which connects the second arm 130 to the base 110. The plurality of wires are collected inside the base 110, and are thus routed to a control device (not illustrated) which is provided outside the base 110 and generally controls the robot 10 along with wires connected to the first motor 111 and the encoder 1.

As mentioned above, a configuration of robot 10 has been described briefly. The robot 10 includes the base 110 which is a first member, the first arm 120 which is a second member rotatably provided with respect to the base 110, and the encoder 1, and the encoder 1 detects a rotation state of the first arm 120 with respect to the base 110. As will be described later, according to the robot 10, detection accuracy in the encoder 1 is high, and thus it is possible to perform highly accurate operation control on the robot 10 by using a detection result in the encoder 1.

Encoder

Hereinafter, the encoder 1 will be described later in detail. Hereinafter, a description will be made of an example of a case where the encoder 1 is incorporated into the robot 10.

FIG. 2 is a sectional view illustrating the encoder provided in the robot illustrated in FIG. 1. FIG. 3 is a diagram for explaining a scale portion provided in the encoder illustrated in FIG. 2. FIG. 4 is a picture illustrating an enlarged dot pattern based on a dithering method. FIG. 5 is a picture illustrating an enlarged dot pattern based on a dithering method, in which a density of dots is lower than in the case illustrated in FIG. 4. In each drawing excluding FIGS. 4 and 5, for convenience of description, a scale of each unit is changed as appropriate, and an illustrated configuration does not necessarily match an actual scale, and illustration of each unit is simplified as appropriate.

As illustrated in FIG. 2, the base 110 of the robot 10 includes a support member 114 supporting the first motor 111 and the first decelerator 112, and stores the first motor 111 and the first decelerator 112 therein. The base 110 is provided with the first arm 120 which is rotatable about the first axis J1.

The first arm 120 includes an arm main body portion 121 which extends along the horizontal direction, and a shaft portion 122 which protrudes downward from the arm main body portion 121, and the two portions are connected to each other. The shaft portion 122 is supported at the base 110 via a bearing 115 so as to be rotatable about the first axis J1, and is also connected to the output shaft of the first decelerator 112. The input shaft of the first decelerator 112 is connected to a rotation shaft 1111 of the first motor 111.

Here, the base 110 is a structural body to which a load based on the dead weight of the base 110 or the mass of other elements supported by the base 110 is applied. Similarly, the first arm 120 is also a structural body to which a load based on the dead weight of the first arm 120 or the mass of other elements supported by the first arm 120 is applied. Materials forming the base 110 and the first arm 120 are not particularly limited, and may employ, for example, metal materials.

In the present embodiment, outer surfaces of the base 110 and the first arm 120 form a part of an outer surface of the robot 10. Exterior members such as a cover and an impact absorbing material may be attached to the outer surfaces of the base 110 and the first arm 120.

The relatively rotated base 110 and first arm 120 are provided with the encoder 1 detecting rotation states thereof.

The encoder 1 includes a scale portion 2 provided at the first arm 120, a detection portion 3 provided at the base 110 and detecting the scale portion 2, an estimation portion 5 estimating relative rotation states of the base 110 and the first arm 120 on the basis of a detection result in the detection portion 3, and a storage portion 6 which is electrically connected to the estimation portion 5.

The scale portion 2 is provided at a portion of the arm main body portion 121 facing the base 110, that is, a portion surrounding the shaft portion 122 on a lower surface of the arm main body portion 121. As illustrated in FIG. 3, the scale portion 2 has irregular patterns disposed along the first axis J1 at positions which are different from the first axis J1. Here, the scale portion 2 is provided on the surface of the first arm 120. Consequently, a member for providing the scale portion 2 is not required to be provided separately from the base 110 and the first arm 120. Thus, it is possible to reduce the number of components. The scale portion 2 is not limited to a case of being directly provided on the surface of the first arm 120, and may be provided on a sheet member adhered to the surface of the first arm 120, and may be provided on a tabular member which is provided to be rotated along with the first arm 120. In other words, a member (rotation portion) provided with the scale portion 2 may be a member which is rotated about the first axis J1 along with the first arm 120 with respect to the base 110.

As illustrated in FIG. 3, the scale portion 2 (irregular pattern) is configured such that a plurality of dots 20 (pattern) which can be imaged by an imaging element 31 are irregularly disposed. Here, the “irregular pattern” indicates that, in a case where the scale portion 2 is rotated over a necessary angle range (in the present embodiment, an angle range in which the first arm 120 can be rotated with respect to the base 110) about the first axis J1, an identical pattern (a pattern which cannot be identified by the estimation portion 5) does not appear twice or more with a size corresponding to a reference image TA which will be described later in a predetermined region (for example, an effective visual field region RU or a retrieval region RS which will be described later) within a captured image G which will be described later obtained by the imaging element 31. Thus, each of a plurality of portions at different positions of the scale portion 2 can be used as a mark 21 for identifying a position of the scale portion 2 in a circumferential direction. As mentioned above, the scale portion 2 can be said to have a plurality of marks 21 for identifying different positions of the scale portion 2 in the circumferential direction. FIG. 3 illustrates a case where the plurality of marks 21 are arranged along a circumference centering on the first axis J1. Positions, sizes, and the number of marks 21 illustrated in FIG. 3 are only examples, and are not limited thereto.

The scale portion 2 (pattern) may be formed by using, for example, an ink jet printer (an example of a printing apparatus) . In this case, a grayscale image which is processed by using a dithering method is output by using an FM screening method which is a method of expressing gradations or grayscales by adjusting a density of the dots 20, and thus the pattern as illustrated in FIG. 4 or 5 are obtained and may be used for the scale portion 2. FIG. 4 illustrates an example of a pattern in a case where a plurality of dots 20 are relatively densely disposed. FIG. 5 illustrates an example of a pattern in a case where a plurality of dots 20 are relatively roughly disposed. In order to obtain such a pattern, an FM screening method may be used alone, and a method (a so-called hybrid screening method) of combining the FM screening method with other methods (for example, an AM screening method which is a method of expressing gradations or grayscales by adjusting a size of a dot) may be used.

Since the patterns of the scale portion 2 are consecutively disposed around the first axis J1, there is less restriction in a position in a rotation direction (circumferential direction) and the degree of freedom is increased when the estimation portion 5 which will be described later generates a reference image (template). Since the patterns of the scale portion 2 are disposed outside the effective visual field region RU of the captured image G in the Y axis direction, a reference image (template) can be generated even if positioning of the scale portion 2 (pattern) for the first arm 120 is not performed with high accuracy, and thus a rotation state can be estimated.

The scale portion 2 may have a gradation which gradually changes along the circumferential direction. In other words, a density (disposition density) of the plurality of dots 20 may change along the periphery of the first axis J1 (rotation axis). A color of the dot 20 (pattern) of the scale portion 2 is not particularly limited, and may be any color, but is preferably different from colors of portions other than the dots 20 of the scale portion 2, and is more preferably black or a dark color. Consequently, a contrast of a captured image obtained by the imaging element 31 can be increased, and, as a result, detection accuracy can be improved.

A shape of the dot 20 (pattern) of the scale portion 2 is illustrated to be a circular shape, but is not limited thereto, and may be, for example, an elliptical shape, a quadrilateral shape, or a deformed shape. The patterns of the scale portion 2 are not limited to dot patterns (repetition of a pattern) such as patterns formed of the plurality of dots 20, and may be, for example, patterns formed of linear lines, patterns formed of curved lines, patterns formed of a combination of at least two of dots, linear lines, and curved lines, or inverse patterns thereof.

The patterns of the scale portion 2 are not limited to patterns formed with ink such as dyes or pigments by using the above-described printing apparatus as long as the patterns can be imaged by the imaging element 31, and may be, for example, patterns based on an irregular shape, or patterns formed on a natural object. The patterns based on an irregular shape may be, for example, irregularities based on roughness or unevenness of a processing surface using etching, cutting, shot blasting, sand blasting, or filing, irregularities using fibers on a surface of paper, a cloth (a nonwoven fabric or a woven fabric), or the like, or irregularities of a coating film surface. The patterns formed on a natural object may be, for example, wood grains. For example, a coating film is formed by using transparent paint with which black beads are mixed, a coating film in which a plurality of black beads are irregularly disposed can be obtained, and the plurality of beads of the coating film may be used for the scale portion 2 as irregular patterns.

The marks 21 of the scale portion 2 are not limited to the illustrated irregular patterns, may use numbers, and may use letters such as roman letters, Arabic letters, and Chinese letters, and may use, for example, symbols, signs, tokens, marks, design, or a one-dimensional barcode or a QR code (registered trademark) other than letters.

The detection portion 3 illustrated in FIG. 2 includes the imaging element 31 provided in the base 110, and an optical system 32 provided in an opening of the base 110. The imaging element 31 images a part (an imaging region RI illustrated in FIG. 3) of the scale portion 2 in the circumferential direction of the scale portion 2 via the optical system 32. A light source which illuminates the imaging region RI of the imaging element 31 may be provided as necessary.

As the imaging element 31, for example, a charge coupled device (CCD) or a complementary metal oxide semiconductor (CMOS) may be used. The imaging element 31 converts a captured image into an electric signal for each pixel so as to output the electric signal. The imaging element 31 may employ a two-dimensional imaging element (area image sensor) or a one-dimensional imaging element (line image sensor). The one-dimensional imaging element is preferably disposed in a direction in which arrangement of pixels are in contact with a turning circle of the arm. In a case where the two-dimensional imaging element is used, a two-dimensional image having a large amount of information can be acquired, and thus it becomes easier to increase the detection accuracy of the marks 21 using template matching which will be described later. As a result, it is possible to detect a rotation state of the first arm 120 with high accuracy. In a case where the one-dimensional imaging element is used, since an image acquisition cycle, that is, a so-called frame rate is high, it is possible to increase a detection frequency, and thus this is advantage in terms of a high speed operation.

The optical system 32 is an image forming optical system disposed between the scale portion 2 and the imaging element 31. The optical system 32 preferably has a telecentric object side (the scale portion 2 side). Consequently, even if a distance between the scale portion 2 and the imaging element 31 varies, a change in an image forming magnification toward the imaging element 31 can be reduced, and, as a result, it is possible to minimize deterioration in detection accuracy in the encoder 1. Particularly, in a case where the optical system 32 is of a bitelecentric type, even if a distance between a lens of the optical system 32 and the imaging element 31 varies, a change in an image forming magnification toward the imaging element 31 can be reduced. Thus, there is an advantage in which assembling of the optical system 32 is facilitated.

Here, as illustrated in FIG. 3, the imaging region RI of the imaging element 31 is set to overlap a part of the scale portion 2 in the circumferential direction on the lower surface of the first arm 120. Consequently, the imaging element 31 can image the mark 21 located in the imaging region RI. Therefore, the mark 21 located in the imaging region RI is read, and thus a rotation state of the first arm 120 can be understood.

The estimation portion 5 illustrated in FIG. 2 estimates relative rotation states of the base 110 and the first arm 120 on the basis of a detection result in the detection portion 3. The rotation states may include, for example, a rotation angle, a rotation speed, and a rotation direction.

Particularly, the estimation portion 5 includes an image recognition circuit 51 which performs image recognition on the marks 21 by performing template matching on a captured image (captured image data) in the imaging element 31 by using a reference image (reference image data), and estimates relative rotation states of the base 110 and the first arm 120 by using a recognition result in the image recognition circuit 51.

Here, the estimation portion 5 is configured to be able to more finely determine a relative rotation angle (hereinafter, also simply referred to as a “rotation angle of the first arm 120”) of the base 110 and the first arm 120 on the basis of a position of an image of the mark 21 in a captured image obtained by the imaging element 31. The estimation portion 5 is configured to be able to obtain a rotation speed on the basis of a time interval at which the marks 21 are detected, or to determine a rotation direction on the basis of an order of the types of detected marks 21. The estimation portion 5 outputs a signal corresponding to the above-described determination result, that is, a signal corresponding to a rotation state of the base 110 and the first arm 120. The signal is input to, for example, a control device (not illustrated), and is used to control an operation of the robot 10.

The estimation portion 5 has a function of cutting out a part of the captured image obtained by the imaging element 31, so as to generate a reference image (template). The generation of a reference image is performed for each relative rotation state before determining a relative rotation state of the base 110 and the first arm 120 or at an appropriate time as necessary. The generated reference image is stored in the storage portion 6 in correlation with each relative rotation state of the base 110 and the first arm 120. The estimation portion 5 performs template matching by using the reference image (template) stored in the storage portion 6. Template matching and an estimation of a rotation state using the template matching will be described later in detail.

The estimation portion 5 may be configured by using, for example, an application specific integrated circuit (ASIC) or a field programmable gate array (FPGA). As mentioned above, the estimation portion 5 is formed of hardware by using the ASIC or the FPGA, and thus it is possible to achieve a high processing speed, miniaturization, and low cost of the estimation portion 5. The estimation portion 5 may be configured to include, for example, a processor such as a central processing unit (CPU) and a memory such as a read only memory (ROM) or a random access memory (RAM). In this case, the processor executes a program stored in the memory as appropriate, and thus the above-described functions can be realized. At least a part of the estimation portion 5 may be incorporated into the control device.

Here, the storage portion 6 stores the reference image (reference image data) along with information regarding a coordinate (a coordinate of a reference pixel which will be described later) in a captured image corresponding to the reference image, and information (angle information) regarding a rotation angle of the first arm 120, for each relative rotation state of the base 110 and the first arm 120. As the storage portion 6, a nonvolatile memory and a volatile memory may be used, but the nonvolatile memory is preferably used from the viewpoint that a state of storing information can be held even if power is not supplied, and power can be saved. The storage portion 6 maybe integrally configured with the estimation portion 5.

Template Matching and Estimation of Rotation State using Template Matching

Hereinafter, a detailed description will be made of template matching and an estimation of a rotation state using template matching in the estimation portion 5. Hereinafter, as an example, a description will be made of a case where a rotation angle is estimated as a rotation state.

Acquisition of Reference Image

In the encoder 1, a reference image used for template matching is acquired before a rotation state of the first arm 120 with respect to the base 110 is estimated by using template matching. The acquisition of a reference image may be performed only once before initial template matching, but may be performed at an appropriate timing as necessary thereafter. In this case, a reference image used for template matching may be updated to an acquired new reference image.

When a reference image is acquired, the first arm 120 is rotated about the first axis J1 with respect to the base 110 as appropriate, and an image of each mark 21 is captured by the imaging element 31 for the plurality of marks 21. Each obtained captured image is trimmed, and thus a reference image of each mark 21 is generated. The generated reference image is stored in the storage portion 6 along with and in correlation with pixel coordinate information and angle information. Hereinafter, this will be described in detail with reference to FIG. 6.

FIG. 6 is a diagram for explaining a captured image obtained by the imaging element provided in the encoder illustrated in FIG. 2.

In a case where the first arm 120 is rotated about the first axis with respect to the base 110, for example, as illustrated in FIG. 6, a mark image 21A which is an image of the mark 21 reflected in the captured image G in the imaging element 31 is moved along circular arcs C1 and C2 in the captured image G. Here, the circular arc C1 is a trajectory drawn by a lower end of the mark image 21A in FIG. 6 due to rotation of the first arm 120 with respect to the base 110, and the circular arc C2 is a trajectory drawn by an upper end of the mark image 21A in FIG. 6 due to rotation of the first arm 120 with respect to the base 110. FIG. 6 illustrates a case where three marks 21 are included in the imaging region RI illustrated in FIG. 3, and, in correspondence thereto, the captured image G illustrated in FIG. 8 includes not only the mark image 21A but also a mark image 21B located on one side in the circumferential direction with respect to the mark image 21A and a mark image 21X located on the other side.

Here, the captured image G obtained through imaging in the imaging element 31 has a shape corresponding to the imaging region RI, and has a rectangular shape having two sides extending in an X axis direction and two sides extending in a Y axis direction. The two sides of the captured image G in the X axis direction are disposed along the circular arcs C1 and C2 if at all possible. The captured image G has a plurality of pixels arranged in a matrix form in the X axis direction and the Y axis direction. Here, a position of a pixel is expressed by a pixel coordinate system (X,Y) indicated by “X” indicating a position of the pixel in the X axis direction and “Y” indicating a position of the pixel in the Y axis direction. A central region excluding an outer periphery of the captured image G is set as an effective visual field region RU, and a pixel at an upper left end of the figure in the effective visual field region RU is set as an origin pixel (0,0) of the pixel coordinate system (X,Y).

In a case where a reference image TA corresponding to the mark image 21A is generated, the first arm 120 is rotated with respect to the base 110 as appropriate, and the mark image 21A is located at a predetermined position (in FIG. 6, on a central line LY set at the center in the X axis direction) in the effective visual field region RU. Here, a rotation angle θA0 of the first arm 120 with respect to the base 110 of when the mark image 21A is located at the predetermined position is acquired in advance through measurement or the like.

The captured image G is trimmed in a rectangular pixel range as a required minimum range including the mark image 21A, and thus the reference image TA (a template for detection of the mark 21) is obtained. The obtained reference image TA is stored in the storage portion 6. In this case, the reference image TA is stored along with and in correlation with angle information regarding the rotation angle θA0, and pixel information regarding a reference pixel coordinate (XA0,YA0) which is a pixel coordinate of a reference pixel (in FIG. 6, the pixel at the upper left end) in the pixel range of the reference image TA. In other words, the reference image TA, the angle information, and the pixel coordinate information are a single template set used for template matching.

Estimation of Rotation State using Template Matching

Next, with reference to FIGS. 9 to 12, a description will be made of template matching using the reference image TA generated as described above.

FIG. 7 is a diagram for explaining template matching in a retrieval region set in the captured image illustrated in FIG. 6. FIG. 8 is a diagram illustrating a state in which a correlation value is deviated by one pixel from a state in which the correlation value is the maximum or the minimum during template matching. FIG. 9 is a diagram illustrating a state in which a correlation value is the maximum or the minimum during template matching. FIG. 10 is a diagram illustrating a state in which a correlation value is deviated by one pixel toward an opposite side to the state illustrated in FIG. 8 from a state in which the correlation value is the maximum or the minimum during template matching.

As illustrated in FIG. 7, when the mark image 21A is present in the effective visual field region RU, template matching is performed on an image of the effective visual field region RU by using the reference image TA. In the present embodiment, the entire effective visual field region RU is set as a retrieval region RS, the reference image TA overlaps the retrieval region RS, and a correlation value of an overlapping portion between the retrieval region RS and the reference image TA is calculated while deviating the reference image TA by one pixel with respect to the retrieval region RS. Here, a pixel coordinate of the reference pixel of the reference image TA is moved by one pixel from a start coordinate PS (origin pixel P0) to an end pixel PE, and a correlation value of an overlapping portion between the retrieval region RS and the reference image TA is calculated for each pixel coordinate of the reference pixel of the reference image TA with respect to the pixels of the entire retrieval region RS. The calculated correlation value is stored in the storage portion 6 in correlation with the pixel coordinate of the reference pixel of the reference image TA as correlation value data between captured image data and reference image data.

The maximum correlation value is selected from among the plurality of correlation values for the pixel coordinates stored in the storage portion 6, and a pixel coordinate (XA1,YA1) of the reference image TA having the selected correlation value is determined as a pixel coordinate of the mark image 21A. In the above-described way, it is possible to detect a position of the mark image 21A in the captured image G.

Here, a subpixel estimation method is preferably used to obtain a pixel coordinate of the mark image 21A. As illustrated in FIGS. 8 to 10, the reference image TA overlaps the mark image 21A in the vicinity of the maximum correlation value. In the state illustrated in FIG. 9, a correlation value is greater than in the states (states of being deviated by one pixel from the state illustrated in FIG. 9) illustrated in FIGS. 8 and 10, and the correlation value is greatest. However, as in the state illustrated in FIG. 9, in a case where the reference image TA does not completely match the mark image 21A, and overlaps the mark image 21A so as to be deviated therefrom, if it is determined that the state illustrated in FIG. 9 is a pixel position of the mark image 21A, a difference therebetween is an error. The difference is a visual field size BX to the maximum. In other words, in a case where the subpixel estimation method is not used, the visual field size BX is the minimum resolution (accuracy). In contrast, if the subpixel estimation method is used, a correlation value for each visual field size BX can be fitted with a parabola (an equal-angle line may also be used), and thus such an inter-correlation value (inter-pixel pitch) can be complemented (approximated). Thus, it is possible to obtain a pixel coordinate of the mark image 21A with higher accuracy. In the above description, as an example, a description has been made of a case where a pixel coordinate at which a correlation value is the maximum is used for a pixel position of the mark image 21A, but template matching may be performed such that a pixel coordinate at which a correlation value is the minimum is used for a pixel position of the mark image 21A.

As mentioned above, the estimation portion 5 the retrieval region RS is set in the effective visual field region RU which is a partial region of the captured image G, and template matching is performed within the retrieval region RS. Consequently, the number of pixels of the retrieval region RS used for template matching can be reduced, and thus a calculation time related to the template matching can be reduced. Thus, even in a case where angular velocity of the first arm 120 about the first axis J1 is high, it is possible to perform highly accurate detection. Even if distortion or blurring of the outer peripheral portion of the captured image G increases due to aberration of the optical system 32 disposed between the imaging element 31 and the marks 21, a region in which such distortion or blurring is small is used as the retrieval region RS, and thus it is possible to minimize deterioration in the detection accuracy. Generation of the reference image TA and template matching may be performed by using the entire region of the captured image G, and, in this case, correction is preferably performed by taking into consideration aberration as necessary.

In the present embodiment, since a distance between the imaging region RI and the first axis J1 is sufficiently long, each of the circular arcs C1 and C2 can be approximated to a substantially straight line in the captured image G. Therefore, a movement direction of the mark image 21A in the captured image G may be considered to match the X axis direction.

Therefore, the mark image 21A illustrated in FIG. 7 is located at a position deviated by the number of pixels (XA1-XA0) in the X axis direction with respect to the reference image TA located at the reference pixel coordinate (XA0,YA0). Therefore, in a case where a distance between the center of the imaging region RI and the first axis J1 is indicated by r, and a width (a visual field size per pixel of the imaging element 31) of a region on the imaging region RI in the X axis direction, corresponding to one pixel of the imaging element 31 is indicated by W, a rotation angle θ of the first arm 120 with respect to the base 110 may be obtained by using Equation (1) as follows.

$\begin{matrix} {\theta = {{\theta \; A\; 0} + {\frac{\left( {{{XA}\; 1} - {{XA}\; 0}} \right) \times W}{2\; r\; \pi} \times {360\lbrack{^\circ}\rbrack}}}} & (1) \end{matrix}$

In Equation (1), (XA1-XA0)×W corresponds to a distance between an actual position corresponding to the reference pixel coordinate (XA0,YA0) of the reference image TA and an actual position corresponding to the pixel coordinate (XA1,YA1) of the reference image TA at which the above-described correlation value is the maximum. 2rπ corresponds to a length of a trajectory of the mark 21 (a length of a circumference) of when the first arm 120 is rotated by 360° with respect to the base 110. θA0 indicates a rotation angle of the first arm 120 with respect to the base 110 of when the mark image 21A is located at a predetermined position as described above. The rotation angle θ is an angle by which the first arm 120 is rotated from a reference state (0°) with respect to the base 110.

The above-described template matching and calculation of the rotation angle θ using the template matching are also performed on other marks 21 in the same manner. Here, a reference image corresponding to each mark 21 is registered such that at least one of the marks 21 is reflected without being omitted in the effective visual field region RU, and template matching can be performed, with respect to any rotation angle θ. Consequently, it is possible to prevent the occurrence of an angle range in which template matching cannot be performed.

In FIG. 6 described above, the marks 21 and the effective visual field region RU are configured such that a single mark 21 is reflected without being omitted in the effective visual field region RU with respect to any rotation angle θ, but the marks 21 and the effective visual field region RU are preferably configured such that a plurality of marks 21 are reflected without being omitted in the effective visual field region RU with respect to any rotation angle θ. In this case, template matching is performed by using two or more reference images corresponding to two or more marks 21 adjacent to each other such that the template matching can be performed on the plurality of marks 21 reflected in the effective visual field region RU with respect to any rotation angle θ. In this case, the two or more reference images may partially overlap each other.

In other words, the imaging element 31 preferably images all of at least two marks 21 among the plurality of marks 21 which are targets of template matching. Consequently, even if one of the two marks 21 imaged by the imaging element 31 cannot be accurately read due to contamination or the like, the other mark 21 can be read, and thus detection can be performed. Thus, there is an advantage in which it becomes easier to ensure high detection accuracy. As mentioned above, the estimation portion 5 preferably performs template matching by simultaneously using a plurality of reference images with respect to the retrieval region RS. Consequently, it is possible to increase detection accuracy. Template matching using a plurality of reference images will be described in detail in a second embodiment.

Determination of Reference Image

FIG. 11 is a diagram for explaining a plurality of marks of the scale portion illustrated in FIG. 3. FIG. 12 is a diagram illustrating a state in which one mark is detected through template matching among the plurality of marks illustrated in FIG. 11. FIG. 13 is a diagram for explaining prediction of a reference image used for post-template matching following the template matching (pre-template matching) illustrated in FIG. 12. FIG. 14 is a flowchart illustrating a method of determining a reference image used for initial template matching. FIG. 15 is a flowchart illustrating a method (prediction method) of determining a reference image used for post-template matching in the first embodiment. In FIG. 11, the patterns of the scale portion 2 are illustrated, but, for convenience of description, the patterns of the scale portion 2 are not illustrated in FIGS. 12 and 13.

As illustrated in FIG. 11, a plurality of marks 21 are set on the scale portion 2 in the rotation direction. FIG. 11 illustrates a state in which five marks 21 i−2 to 21 i+2 from (i−2)-th to (i+2)-th are reflected in the captured image G. Here, i is a number attached to each of the mark 21 in an arrangement order thereof, and is an integer of 1 or more and n or less in a case where the number of marks 21 set on the scale portion 2 is n (where n is an integer of 3 or more).

As illustrated in FIG. 12, the retrieval region RS is set in the captured image G. A single mark 21 is set in the retrieval region RS at all times without being omitted. In FIG. 12, the mark 21 i is reflected in the retrieval region RS, and the estimation portion 5 performs template matching by using a reference image (hereinafter, also referred to as a “reference image i”) corresponding to the mark 21 i as described above, so as to detect a position of the mark 21 i. The estimation portion 5 estimates a rotation state as described above on the basis of the detected position.

Here, in a case where the scale portion 2 is rotated, the mark 21 i is moved in the rotation direction (the leftward-and-rightward direction in FIG. 12) of the scale portion 2 in the retrieval region RS due to the rotation. In this case, the estimation portion 5 performs template matching (hereinafter, also referred to as “pre-template matching”) while causing the reference image i to track the movement of the mark 21 i, and thus sequentially detects a position of the mark 21 i.

A position of the mark 21 i can be detected when the mark 21 i is reflected in the retrieval region RS. In a case where the mark 21 i is not reflected in the retrieval region RS due to rotation of the scale portion 2, the mark 21 i−1 or the mark 21 i+1 adjacent to the mark 21 i is reflected in the retrieval region RS. Therefore, in a case where the mark 21 i is not reflected in the retrieval region RS, the estimation portion 5 performs template matching (hereinafter, also referred to as “post-template matching”) by using a reference image (hereinafter, also referred to as a “reference image i−1”) corresponding to the mark 21 i−1 or a reference image (hereinafter, also referred to as a “reference image i+1”) corresponding to the mark 21 i+1, so as to detect a position of the mark 21 i−1 or the mark 21 i+1.

Here, the estimation portion 5 predicts a reference image used for post-template matching on the basis of a result of the pre-template matching (a detected position of the mark 21 i). More specifically, a first region R1 (first detection region) is set to be adjacent to one side (the right side in FIG. 12) of the retrieval region RS in the movement direction of the mark 21 i, and a second region R2 (second detection region) is set to be adjacent to the other side (the left side in FIG. 12) thereof. As illustrated in FIG. 13, in a case where the mark 21 i reaches the second region R2, in other words, in a case where a left end of the mark 21 i in the figure is deviated from the retrieval region RS, the estimation portion 5 predicts that a reference image used for post-template matching is a reference image corresponding to the mark 21 i+1. On the other hand, although not illustrated, in a case where the mark 21 i reaches the first region R1, in other words, in a case where a right end of the mark 21 i in the figure is deviated from the retrieval region RS, the estimation portion 5 predicts that a reference image used for post-template matching is a reference image corresponding to the mark 21 i−1.

As mentioned above, a reference image used for post-template matching is predicted, and thus a position of the mark 21 i+1 or the mark 21 i−1 can be detected early in the post-template matching. Thus, it is possible to reduce an idle state in which a position of the mark 21 is not detected, and thus to improve detection accuracy.

In contrast, in a case where the above-described prediction of a reference image used for post-template matching is not performed, if the mark 21 i is not reflected in the retrieval region RS, it is necessary that template matching is performed by sequentially using reference images corresponding to the n marks 21 in a round robin manner, and a reference image having the greatest correlation value is selected. Thus, a calculation amount required for template matching in the estimation portion 5 is increased, and, as a result, there is a probability that a time of an idle state in which a position of the mark 21 is not detected may be increased, and thus detection accuracy may be reduced.

In FIGS. 12 and 13, the first region R1 and the second region R2 do not overlap the retrieval region RS, but the next mark 21 may be reflected in the retrieval region RS when the previous mark 21 reaches the first region R1 or the second region R2, and at least parts of the first region R1 and the second region R2 may be set to overlap the retrieval region RS.

Hereinafter, a description will be made of a flow of a determination of a reference image in the estimation portion 5 with reference to FIGS. 14 and 15.

FIG. 14 is a flowchart illustrating a method of determining a reference image used for initial template matching. FIG. 15 is a flowchart illustrating a method (prediction method) of determining a reference image used for post-template matching in the first embodiment.

In initial template matching, first, as illustrated in FIG. 14, 1 is set as i (step S31). Retrieval is performed in the retrieval region RS by using a reference image i (initially, i=1), and the maximum correlation value Ci is stored in the storage portion 6 in correlation with the number i (step S32). Thereafter, it is determined whether or not the number i is the same as N (step S33), and, in a case where the number is not the same as N (NO in step S33), i+1 is set as i (step S34), and the flow proceeds to the above step S32. Consequently, the maximum correlation values Ci (C1 to CN) from the reference image i (where i=1) to the reference image i (where i=N) are stored in the storage portion 6 in correlation with the number i (where i is 1 to N).

In a case where the number i is the same as N (YES in step S33), the number i of the maximum correlation value Ci which is greatest among the maximum correlation values Ci (C1 to CN) from the reference image i (where i=1) to the reference image i (where i=N) is obtained on the basis of the information stored in the storage portion 6 (step S35), and the reference image i is determined (step S36).

As mentioned above, the estimation portion 5 obtains the maximum correlation value Ci between the captured image G and each reference image by sequentially using N (three or more) reference images with respect to the captured image G before template matching performed first, and selects at least one reference image from among the N (three or more) reference images on the basis of the maximum correlation value. Consequently, it is possible to determine the reference image i used for template matching in an initial state (before template matching is started). After the reference image i is determined, the mark 21 i reflected in the retrieval region RS is specified, and thus prediction of a reference image is performed according to the following flow.

First, as illustrated in FIG. 15, a position of the mark 21 i is detected through template matching using the reference image i (step S11). Next, an angle A which is a rotation angle of the scale portion 2 is calculated on the basis of the detected position (step S12). The angle A which is a calculation result is output (step S13).

Next, it is determined whether or not the reference image i tracking the mark 21 i reaches the second region R2 (step S14). In a case where the reference image i reaches the second region R2 (YES in step S14), i+1 is set as i (step S15). In other words, in this case, a reference image used for post-template matching is predicted to be the reference image i+1 corresponding to the mark 21 i+1. Thereafter, it is determined whether or not there is a finish instruction (step S18), and, in a case where there is no finish instruction (NO in step S18), the flow proceeds to the above step S11, and post-template matching using the reference image i+1 is performed.

On the other hand, in a case where the reference image i tracking the mark 21 i does not reach the second region R2 (NO in step S14), it is determined whether or not the reference image i tracking the mark 21 i reaches the first region R1 (step S16). In a case where the reference image i reaches the first region R1 (YES in step S16), i−1 is set as i (step S17). In other words, in this case, a reference image used for post-template matching is predicted to be the reference image i−1 corresponding to the mark 21 i−1. Thereafter, it is determined whether or not there is a finish instruction (step S18), and, in a case where there is no finish instruction (NO in step S18), the flow proceeds to the above step S11, and post-template matching using the reference image i−1 is performed.

In a case where the reference image i tracking the mark 21 i reaches neither the first region R1 nor the second region R2 (NO in step S14 and NO in step S16), the above steps S11 to S13 are repeated until the reference image i reaches the first region R1 or the second region R2 or there is a finish instruction.

As described above, the encoder 1 includes the base 110 which is a base portion, the scale portion 2 which is provided to be relatively rotatable with respect to the base 110 and has three or more different marks 21, the imaging element 31 which is disposed in the base 110 and images the marks 21, and the estimation portion 5 which selects at least one reference image from among three or more reference images, performs template matching on a captured image in the imaging element 31 by using the reference image, so as to detect positions of the marks 21, and estimates a rotation state of the scale portion 2 with respect to the base 110. The estimation portion 5 predicts a reference image to be used for post-template matching on the basis of a result of pre-template matching, and performs the post-template matching by using the predicted reference image.

According to the encoder 1, template matching is used, and thus a rotation state of the scale portion 2 with respect to the base 110 can be estimated with high accuracy even without using high definition marks 21, and, as a result, it is possible to increase detection accuracy. Since a reference image to be used for post-template matching is predicted, it is not necessary to retrieve a reference image to be used for the post-template matching from a plurality of reference images when pre-template matching is replaced with the post-template matching, and it is possible to increase a processing speed. As a result, it becomes easier to ensure an effect of increasing detection accuracy as described above.

Here, the scale portion 2 is relatively rotatable with respect to the base 110 (base portion). Consequently, it is possible to realize the encoder 1 which is a rotary encoder.

The encoder 1 includes the storage portion 6 storing three or more reference images as described above. Consequently, template matching can be performed by selecting an appropriate reference image stored in the storage portion 6.

In template matching which is consecutively performed twice, the estimation portion 5 predicts a reference image used for template matching performed later when a position of the mark 21 detected in template matching performed first is present in the retrieval region RS. Consequently, it is possible to make template matching performed first smoothly transition to template matching performed later.

Second Embodiment

FIG. 16 is a diagram illustrating a state in which two marks are detected through template matching among a plurality of marks in an encoder according to a second embodiment of the invention. FIG. 17 is a diagram for explaining prediction of a reference image used for post-template matching following the template matching (pre-template matching) illustrated in FIG. 15. FIG. 18 is a flowchart illustrating a method (prediction method) of determining a reference image used for post-template matching in the second embodiment.

Hereinafter, the second embodiment will be described focusing on a difference from the above-described embodiment, and a description of the same content will be omitted.

The present embodiment is the same as the above-described first embodiment except for a setting range of a retrieval region and a reference image prediction method.

In the present embodiment, as illustrated in FIG. 16, the retrieval region RS is set such that two marks 21 are reflected without being omitted at all times. In FIG. 16, the marks 21 i−1 and 21 i are reflected in the retrieval region RS, and the estimation portion 5 performs template matching as described above by using reference images corresponding to marks 21 i−1 and 21 i, so as to detect each of positions of the marks 21 i−1and 21 i. The estimation portion 5 estimates a rotation state on the basis of the detected positions as described above. As mentioned above, a rotation state (for example, a rotation angle) is obtained on the basis of detected positions of the two marks 21 i−1 and 21 i, and thus it is possible to increase detection accuracy of a rotation state.

As illustrated in FIG. 17, in a case where the mark 21 i−1 reaches the second region R2, in other words, in a case where a left end of the mark 21 i−1 in the figure is deviated from the retrieval region RS, the estimation portion 5 predicts that a reference image used for post-template matching is a reference image corresponding to the mark 21 i+1. On the other hand, although not illustrated, in a case where the mark 21 i reaches the first region R1, in other words, in a case where a right end of the mark 21 i in the figure is deviated from the retrieval region RS, the estimation portion 5 predicts that a reference image used for post-template matching is a reference image corresponding to the mark 21 i−2.

Hereinafter, with reference to FIG. 18, a description will be made of a flow of prediction of a reference image in the estimation portion 5. A method of determining a reference image used for initial template matching may employ the same method as in the above-described first embodiment. After the reference image i is determined, the marks 21 i−1 and 21 i reflected in the retrieval region RS are specified, and thus prediction of a reference image is performed according to the following flow.

First, as illustrated in FIG. 18, steps S11 and S12 are sequentially executed in the same manner as in the above-described first embodiment. Next, a position of the mark 21 i−1 is detected through template matching using the reference image i−1 (step S21), and an angle B which is a rotation angle of the scale portion 2 is calculated on the basis of the detected position (step S22). The angle B which is a calculation result is output (step S23).

Next, it is determined whether or not the reference image i−1 tracking the mark 21 i−1 reaches the second region R2 (step S14). In a case where the reference image i−1 reaches the second region R2 (YES in step S24), i+1 is set as i (step S15). In other words, in this case, a reference image used for post-template matching is predicted to be the reference images i and i+1 corresponding to the marks 21 i and 21 i+1. Thereafter, it is determined whether or not there is a finish instruction (step S18), and, in a case where there is no finish instruction (NO in step S18), the flow proceeds to the above step S11, and post-template matching using the reference images i and i+1 is performed.

On the other hand, in a case where the reference image i−1 tracking the mark 21 i−1 does not reach the second region R2 (NO in step S24), it is determined whether or not the reference image i tracking the mark 21 i reaches the first region R1 (step S16). In a case where the reference image i reaches the first region R1 (YES in step S16), i−1 is set as i (step S17). In other words, in this case, reference images used for post-template matching is predicted to be the reference images i−1 and i−2 corresponding to the mark 21 i−1 and 21 i−2. Thereafter, it is determined whether or not there is a finish instruction (step S18), and, in a case where there is no finish instruction (NO in step S18), the flow proceeds to the above step S11, and post-template matching using the reference images i−1 and i−2 is performed.

In a case where the reference image i−1 tracking the mark 21 i−1 does not reach the first region R1 (NO in step S24), and the reference image i tracking the mark 21 i does not reach the second region R2 (NO in step S16), the above steps S11 to S13 are repeated until the reference image i−1 tracking the mark 21 i−1 does not reach the first region R1, the reference image i−1 tracking the mark 21 i−1 reaches the first region R1, the reference image i tracking the mark 21 i reaches the second region R2, or there is a finish instruction.

According to the second embodiment described above, it is possible to achieve the same effect as in the above-described first embodiment.

Third Embodiment

FIG. 19 is a perspective view illustrating a robot according to a third embodiment of the invention. Hereinafter, a base 210 side of a robot 10C will be referred to as a “basal end side”, and an end effector side will be referred to as a “distal end side”.

Hereinafter, the third embodiment will be described focusing on a difference from the above-described embodiments, and a description of the same content will be omitted.

The robot 10C illustrated in FIG. 19 is a vertical articulated (six-axis) robot. The robot 10C has the base 210 and a robot arm 200, and the robot arm 200 includes a first arm 220, a second arm 230, a third arm 240, a fourth arm 250, a fifth arm 260, and a sixth arm 270, and these arms are connected to each other in this order toward the distal end side from the basal end side. For example, an end effector such as a hand holding precision equipment or components is attachably and detachably attached to a distal end of the sixth arm 270. Although not illustrated, the robot 10C includes a robot control device (control unit) such as a personal computer (PC) controlling an operation of each portion of the robot 10C.

Here, the base 210 is fixed to, for example, a floor, a wall, or a ceiling. The first arm 220 is rotatable about a first rotation axis O1 with respect to the base 210. The second arm 230 is rotatable about a second rotation axis O2 which is orthogonal to the first rotation axis O1 with respect to the first arm 220. The third arm 240 is rotatable about a third rotation axis O3 which is parallel to the second rotation axis O2 with respect to the second arm 230. The fourth arm 250 is rotatable about a fourth rotation axis O4 which is orthogonal to the third rotation axis O3 with respect to the third arm 240. The fifth arm 260 is rotatable about a fifth rotation axis O5 which is orthogonal to the fourth rotation axis O4 with respect to the fourth arm 250. The sixth arm 270 is rotatable about the sixth rotation axis O6 which is orthogonal to the fifth rotation axis O5 with respect to the fifth arm 260. With respect to the first rotation axis O1 to the sixth rotation axis O6, the term “perpendicular” also includes a case where an angle formed between two axes is deviated from 90° within a range of ±5°, and the term “parallel” also includes a case where one of two axes is inclined with respect to the other within a range of ±5°.

Although not illustrated, each connection portion (joint) of the base 210 and the first arm 220 to the sixth arm 270 is provided with a drive source including a motor and a decelerator. Here, a drive source which rotates the first arm 220 with respect to the base 210 is provided with the encoder 1. A detection result in the encoder 1 is input to, for example, the robot control device (not illustrated), and is used to control driving of the drive source which rotates the first arm 220 with respect to the base 210. Although not illustrated, encoders are provided in other joints, and the encoder 1 may be used as the encoders.

As mentioned above, the robot 10C includes the base 210 which is a first member, and the first arm 220 which is a second member provided to be rotatable with respect to the base 210, and the encoder 1 of the first embodiment or the second embodiment, and the encoder 1 detects a rotation state of the first arm 220 with respect to the base 210. According to the robot 10C, detection accuracy in the encoder 1 is high, and thus it is possible to control an operation of the robot 10C with high accuracy by using a detection result in the encoder 1.

In the above description, a description has been made of a case where the encoder 1 detects a rotation state of the first arm 220 with respect to the base 210, but the encoder 1 may be provided in another joint so as to detect a rotation state of another arm. In this case, an arm on one side with respect to the joint may be regarded as a first member, and an arm on the other side may be regarded as a second member.

2. Printer

FIG. 20 is a diagram illustrating a printer of an embodiment of the invention.

A printer 1000 illustrated in FIG. 20 is a label printing device including a drum-shaped platen. In the printer 1000, a single sheet S (web) such as a paper type or a film type as a recording medium of which both ends are wound on a delivery shaft 1120 and a winding shaft 1140 in a roll form is hung between the delivery shaft 1120 and the winding shaft 1140, and the sheet S is transported from the delivery shaft 1120 to the winding shaft 1140 along a transport path Sc hung in the above-described way. The printer 1000 is configured to record (form) an image on the sheet S by discharging a functional liquid onto the sheet S transported along the transport path Sc.

The printer 1000 is configured to include a delivery portion 1102 which delivers the sheet S from the delivery shaft 1120, a process portion 1103 which records an image on the sheet S delivered from the delivery portion 1102, a laser scanner device 1007 which cuts out the sheet S on which the image is recorded in the process portion 1103, and a winding portion 1104 which winds the sheet S on the winding shaft 1140.

The delivery portion 1102 includes the delivery shaft 1120 winding an end of the sheet S thereon, and a driven roller 1121 winding the sheet S extracted from the delivery shaft 1120 thereon.

In the process portion 1103, the sheet S delivered from the delivery portion 1102 is supported by a platen drum 1130 as a support portion, and a recording head 1151 or the like disposed in a head unit 1115 which is disposed along an outer circumferential surface of the platen drum 1130 performs an appropriate process so as to record an image on the sheet S.

The platen drum 1130 is a circular drum which is rotatably supported by a support mechanism (not illustrated) centering on a drum shaft 1130 s, and winds the sheet S transported from the delivery portion 1102 to the winding portion 1104 on a rear surface (a surface on an opposite side to a recording surface) side thereon. The platen drum 1130 is driven to rotate in a transport direction Ds of the sheet S as a result of receiving friction force with the sheet S, and supports the sheet S from the rear surface side in a range Ra in the circumferential direction thereof. Here, the process portion 1103 is provided with driven rollers 1133 and 1134 turning the sheet S on both sides of the winding portion to the platen drum 1130. Driven rollers 1121 and 1131 and a sensor Se are provided between the delivery shaft 1120 and the driven roller 1133, and driven rollers 1132 and 1141 are provided between the winding shaft 1140 and the driven roller 1134.

The process portion 1103 includes a head unit 1115, and the head unit 1115 is provided with four recording heads 1151 corresponding to yellow, cyan, magenta, and black. Each of the recording heads 1151 faces a front surface of the sheet S wound on the platen drum 1130 with a slight clearance (platen gap), and discharges a functional liquid of a corresponding color from nozzles in an ink jet method. The respective recording heads 1151 discharge functional liquids onto the sheet S transported in the transport direction Ds, and thus a color image is formed on the front surface of the sheet S.

Here, as the functional liquids, ultraviolet (UV) ink (photocurable ink) which is cured when being irradiated with ultraviolet rays (light) is used. Thus, the head unit 1115 of the process portion 1103 is provided with first UV sources 1161 (light irradiation portions) among the plurality of recording heads 1151 in order to temporarily cure the UV ink and to fix the UV ink to the sheet S. A second UV source 1162 as a curing portion is provided on a downstream side of the transport direction Ds with respect to the plurality of recording heads 1151 (head unit 1115).

The laser scanner device 1007 is provided to partially cut out the sheet S on which an image is recorded, or to divide the sheet S. Laser light which is caused to oscillate by a laser oscillator 1401 of the laser scanner device 1007 is applied to the sheet S which is a processed object via a first lens 1403 and a first mirror 1407 or a second mirror 1409 of which positions or rotation positions (angles) are controlled by drive devices 1402, 1406 and 1408 including the encoder 1 of the first embodiment or the second embodiment. As mentioned above, an irradiation position of laser light LA applied to the sheet S is controlled by the respective drive devices 1402, 1406 and 1408, and thus the laser light LA can be applied to a desired position on the sheet S. In the sheet S, a portion thereof irradiated with the laser light LA is melted, and thus the sheet S is partially cut out or divided.

The printer 1000 described above includes the encoder 1 of the first embodiment or the second embodiment. According to the printer 1000, detection accuracy in the encoder 1 is high, and thus it is possible to control an operation of the printer 1000 with high accuracy by using a detection result in the encoder 1.

As mentioned above, the encoder, the robot, and the printer according to the preferred embodiments of the invention have been described, but the invention is not limited thereto, and a configuration of each portion may be replaced with any configuration having the same function. Any other constituent element may be added thereto. The configurations of the above-described two or more embodiments may be combined with each other.

In the embodiments, a description has been made of a case where the encoder according to the embodiments of the invention is applied to a rotary encoder, but this is only an example, and the encoder according to the embodiments may be applied to a linear encoder. In this case, the scale portion is provided to be relatively movable with respect to the base portion, and a plurality of marks are disposed along a movement direction thereof. The estimation portion performs template matching on a captured image in the imaging element by using a reference image, so as to detect a position of the mark, and estimates a movement state of the scale portion with respect to the base portion. The movement state may include, for example, a movement distance, a movement speed, or a movement direction.

The encoder according to the embodiments of the invention may be applied to any type such as an absolute type and an incremental type.

In the embodiments, a description has been made of an exemplary configuration in which the base of the robot is a “base portion (first member)”, and the first arm is a “rotation portion (second member)”, but this is only an example, and one of any two members which are relatively rotated may be a “base portion”, and the other member is a “rotation portion”. A location where the encoder is provided is not limited to a joint between the base and the first arm, and may be a joint between any two arms which are relatively rotated. A location where the encoder is provided is not limited to a joint of the robot.

In the above-described embodiments, the number of arms of the robot is one, but the number of arms of the robot is not limited thereto, and may be, for example, two or more. In other words, the robot according to the embodiments of the invention may be, for example, a robot with two arms or a robot with a plurality of arms.

In the embodiments, the number of arms of the robot is two or six, but the number of arms of the robot is not limited thereto, and may be, for example, one, or three or more and five rotation less, or seven or more.

In the above-described embodiments, a location where the robot according to the embodiments of the invention is provided is not limited to a floor surface, and may be, for example, a ceiling surface or a sidewall surface, and may be a moving object such as an automatic guided vehicle (AGV). The robot according to the embodiments of the invention is not limited to being provided to be fixed to a structure such as a building, and may be, for example, a leg type walking (traveling) robot having legs.

The encoder according to the embodiments of the invention is not limited to the above-described printer, and may be used for various printers such as an industrial printer and a consumer printer. In a case where the encoder according to the embodiments of the invention is used for a printer, a location where the encoder is provided is not limited to the above-described locations, and may be used for a paper feeding mechanism, and a movement mechanism of a carriage mounted with an ink head of an ink jet printer, for example.

The entire disclosure of Japanese Patent Application No. 2017-189321, filed Sep. 29, 2017 is expressly incorporated by reference herein. 

What is claimed is:
 1. An encoder comprising: a base portion; a scale portion that is provided to be relatively movable or rotatable with respect to the base portion, and has three or more marks which are different from each other; an imaging element that is disposed in the base portion, and images the marks; and an estimation portion that selects at least one reference image from among three or more reference images, performs template matching on a captured image in the imaging element by using the reference image, so as to detect positions of the marks, and estimates a movement state or a rotation state of the scale portion with respect to the base portion, wherein, in template matching consecutively performed twice, the estimation portion predicts a reference image to be used for template matching performed later on the basis of a result of template matching performed first.
 2. The encoder according to claim 1, wherein the scale portion is relatively rotatable with respect to the base portion.
 3. The encoder according to claim 1, further comprising: a storage portion that stores the three or more reference images.
 4. The encoder according to claim 1, wherein the estimation portion sets a retrieval region in a partial region of the captured image, and performs the template matching in the retrieval region.
 5. The encoder according to claim 4, wherein, in a case where positions of the marks detected in the template matching performed first are present in the retrieval region, the estimation portion predicts a reference image used for the template matching performed later.
 6. The encoder according to claim 4, wherein the estimation portion performs template matching by simultaneously using a plurality of reference images with respect to the retrieval region.
 7. The encoder according to claim 1, wherein, before the template matching performed first, the estimation portion obtains the maximum correlation value of the captured image and each reference image by sequentially using the three or more reference images with respect to the captured image, and selects at least one reference image from among the three or more reference images on the basis of the maximum correlation value.
 8. A robot comprising: a first member; a second member that is provided to be rotatable with respect to the first member; and the encoder according to claim 1, wherein the encoder detects a rotation state of the second member with respect to the first member.
 9. A robot comprising: a first member; a second member that is provided to be rotatable with respect to the first member; and the encoder according to claim 2, wherein the encoder detects a rotation state of the second member with respect to the first member.
 10. A robot comprising: a first member; a second member that is provided to be rotatable with respect to the first member; and the encoder according to claim 3, wherein the encoder detects a rotation state of the second member with respect to the first member.
 11. A robot comprising: a first member; a second member that is provided to be rotatable with respect to the first member; and the encoder according to claim 4, wherein the encoder detects a rotation state of the second member with respect to the first member.
 12. A robot comprising: a first member; a second member that is provided to be rotatable with respect to the first member; and the encoder according to claim 5, wherein the encoder detects a rotation state of the second member with respect to the first member.
 13. A robot comprising: a first member; a second member that is provided to be rotatable with respect to the first member; and the encoder according to claim 6, wherein the encoder detects a rotation state of the second member with respect to the first member.
 14. A robot comprising: a first member; a second member that is provided to be rotatable with respect to the first member; and the encoder according to claim 7, wherein the encoder detects a rotation state of the second member with respect to the first member.
 15. A printer comprising the encoder according to claim
 1. 16. A printer comprising the encoder according to claim
 2. 17. A printer comprising the encoder according to claim
 3. 18. A printer comprising the encoder according to claim
 4. 19. A printer comprising the encoder according to claim
 5. 20. A printer comprising the encoder according to claim
 6. 